'use strict'
/*第一题*/
function indexOf(arr, item) {
 return arr.indexOf(item) 
 }
console.log(indexOf([1,2,3,4,],3));

/*第二题*/
function sum(arr) {
    let b = 0
    for (let i = 0; i < arr.length; i++) {
        b += arr[i]
    }
    return b
}
console.log(sum([ 1, 2, 3, 4 ]));


/*第三题*/

var s1 = new Set([1,2,3,4]); 
s1.add(10);
console.log(s1);

/*第四题*/
function concat(arr1, arr2) {
    let brr = []
    brr = arr1.concat(arr2)
    return brr
}
console.log(concat([1, 2, 3, 4], ['a', 'b', 'c', 1]));
   
/*第五题*/
    function square(arr) {
        let brr = []
        for (let i = 0; i < arr.length; i++) {
            brr.push(arr[i]*arr[i])
        }
        return brr
    }
    console.log(square([1, 2, 3, 4]));


  /*第六题*/
  function area_of_circle(r, pi) {
    if (pi===null||pi===undefined) {
        pi=3.14
    }
    return pi*r*r
}
console.log(area_of_circle(2));

  /*第七题*/
console.log(`======= 第7题 =======`);
function abc(){
    let a = $('div>[name=" aa "')
    let a1 = $('[name=aa]')
    let b = []
    let c = []
    for(let i of a1){
        b.push(i)
        // console.log(i);
    }
    for(let i of a){
        b.push(i)
        // console.log(i);
    }
    for (let i = 0; i < b.length; i++) {
        if (b[i].checked) {
            c.push(i)
        }
    }
    alert('选中了： '+c)
}
/*第九题*/
console.log(`======= 第9题 =======`);
var btn = $('#btnSubmit')
btn.click(function aa(){
    let user = $('#username').val()
    let pass = $('#password').val()
    if (user.length<1) {
        alert('用户名不能为空')
    }
    if (pass.length<6) {
        alert('你输入的密码长度不可以少于6位')
    }
})

/*第十题*/
console.log(`======= 第10题 =======`);
function test(){
   let text = document.getElementById('feedBack')
   let number = document.getElementById('number')
   if (text.value.length>=20) {
       text.slice(0,19)
       number.value = text.length
   }
}

